﻿using System;
using System.Collections.Generic;

using System.Windows;
using System.Windows.Controls;

using System.Windows.Input;
using System.Windows.Navigation;

using EagleJournal.Controls;

namespace EagleJournal
{
    public struct ClientPurchaseOrderInfo
    {
        public string Description;
        public string Amount;

        public string Deadline;
    }

	public partial class DialogViewOrder : UserControl
    {
        public static readonly  RoutedEvent
            InvokeDialogConfirmEvent = EventManager.RegisterRoutedEvent("InvokeDialogConfirm", RoutingStrategy.Direct, typeof(RoutedEventHandler), typeof(DialogViewOrder));
        public event            RoutedEventHandler
            InvokeDialogConfirm
        {
            add     { this.AddHandler(InvokeDialogConfirmEvent, value); }
            remove  { this.RemoveHandler(InvokeDialogConfirmEvent, value); }
        }

		public DialogViewOrder()
		{
			this.InitializeComponent();
		}

        private void ButtonClose_Click  (object sender, RoutedEventArgs e)
        {
            this.RaiseEvent(new RoutedEventArgs(InvokeDialogConfirmEvent));
        }

        public  void ClearData          ()
        {
            this.Data.Items.Clear();
            this.TextPOName.Text = "Purchase Orders for {0}";
        }

        public  void PassData           (string name, List<ClientPurchaseOrderInfo> data)
        {
            this.TextPOName.Text = string.Format(this.TextPOName.Text, name);

            foreach (ClientPurchaseOrderInfo po in data)
            {
                ListPOInfo poinfo = new ListPOInfo()
                {
                    PODeadline  = po.Deadline,
                    POSerialID  = po.Amount,
                    Content     = po.Description,
                };

                this.Data.Items.Add(poinfo);
            }
        }
	}
}